:- use_module(library(clpfd)).

count(0,[]).
%count(Count,[Head|Tail]) :- count(TailCount,Tail),Count #= Tailcount + 1. 
count(Count,[Head|Tail]) :- count(TailCount,Tail),Count is TailCount + 1. 

sum(0,[]).
sum(Total,[Head|Tail]):-sum(Sum,Tail),Total is Head+Sum.

average(Average,List):-sum(Sum,List),count(Count,List),Average is Sum/Count.
